﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Display;
using System.Drawing;
using EAGL.Core;

namespace EAGL.Display.Rendering
{
    public static class SymbolCreator
    {
        static Random rand;

        public static ISimpleFillSymbol CreateDefaultSimpleFillSymbol(Color color, Color outlineColor)
        {
            ISimpleFillSymbol fsym = new SimpleFillSymbolClass();
            fsym.Color = ColorManager.GetESRIColor(color);
            fsym.Style = esriSimpleFillStyle.esriSFSSolid;
            ILineSymbol lsym = new SimpleLineSymbolClass();
            lsym.Color = ColorManager.GetESRIColor(outlineColor);
            lsym.Width = 1;
            fsym.Outline = lsym;
            return fsym;
            
        }
        
        public static ISimpleFillSymbol CreateRandomSimpleFillSymbol(ISimpleFillSymbol defaultSymbol, bool randomFillColor, bool randomFillStyle, bool randomOutlineColor, bool randomOutlineWidth)
        {
           // initialize the random engine 
           if (rand == null)
                rand = new Random();
           
            ISimpleFillSymbol fsym = new SimpleFillSymbolClass();
            fsym.Color = randomFillColor ? ColorManager.GetESRIRandomColor() : defaultSymbol.Color;
            fsym.Style = randomFillStyle ? (esriSimpleFillStyle)StyleManager.GetRandomSimpleFillStyle() : defaultSymbol.Style;
            ILineSymbol lsym = new SimpleLineSymbolClass();
            lsym.Color = randomOutlineColor ? ColorManager.GetESRIRandomColor() : defaultSymbol.Outline.Color;
            lsym.Width = randomOutlineWidth ? rand.Next(4) : defaultSymbol.Outline.Width;
            fsym.Outline = lsym;
            return fsym;
        }
    }
}
